unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  SysUtils, Forms, Dialogs,
  ComCtrls, StdCtrls, MaskEdit, Menus, ExtCtrls, INIFiles, synaser, Classes;

type

  { TForm1 }

  TForm1 = class(TForm)
    CallSign1: TMaskEdit;
    CallSign2: TMaskEdit;
    CallSign3: TMaskEdit;
    CallSign4: TMaskEdit;
    CallSign5: TMaskEdit;
    clear: TButton;
    ComboBox1: TComboBox;
    comment1: TEdit;
    comment2: TEdit;
    comment3: TEdit;
    comment4: TEdit;
    comment5: TEdit;
    GroupBox3: TGroupBox;
    GroupBox4: TGroupBox;
    GroupBox5: TGroupBox;
    GroupBox6: TGroupBox;
    GroupBox7: TGroupBox;
    Label12: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Label15: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    Label20: TLabel;
    Label21: TLabel;
    Label22: TLabel;
    Label23: TLabel;
    Label24: TLabel;
    Label25: TLabel;
    Label26: TLabel;
    Label27: TLabel;
    Label28: TLabel;
    Label29: TLabel;
    Label30: TLabel;
    Label31: TLabel;
    Label32: TLabel;
    Label33: TLabel;
    Label34: TLabel;
    Label35: TLabel;
    Label36: TLabel;
    Label37: TLabel;
    Label38: TLabel;
    Label39: TLabel;
    Label40: TLabel;
    Label41: TLabel;
    Label42: TLabel;
    Label43: TLabel;
    Label44: TLabel;
    Label45: TLabel;
    Label46: TLabel;
    Label6: TLabel;
    latitude1: TEdit;
    latitude2: TEdit;
    latitude3: TEdit;
    latitude4: TEdit;
    latitude5: TEdit;
    longtitude1: TEdit;
    longtitude2: TEdit;
    longtitude3: TEdit;
    longtitude4: TEdit;
    longtitude5: TEdit;
    Memo1: TMemo;
    MenuItem2: TMenuItem;
    napiecie: TCheckBox;
    odczytaj: TButton;
    Path3: TComboBox;
    Path4: TComboBox;
    Path5: TComboBox;
    Path6: TComboBox;
    Path7: TComboBox;
    ProgressBar1: TProgressBar;
    send: TButton;
    symbol1: TComboBox;
    symbol2: TComboBox;
    symbol3: TComboBox;
    symbol4: TComboBox;
    symbol5: TComboBox;
    table1: TComboBox;
    table2: TComboBox;
    table3: TComboBox;
    table4: TComboBox;
    table5: TComboBox;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    TabSheet3: TTabSheet;
    TabSheet4: TTabSheet;
    TabSheet5: TTabSheet;
    MainMenu1: TMainMenu;
    MenuItem1: TMenuItem;
    MenuItem10: TMenuItem;
    MenuItem11: TMenuItem;
    MenuItem3: TMenuItem;
    MenuItem4: TMenuItem;
    MenuItem5: TMenuItem;
    MenuItem6: TMenuItem;
    MenuItem7: TMenuItem;
    MenuItem8: TMenuItem;
    MenuItem9: TMenuItem;
    CallSign: TMaskEdit;
    table: TComboBox;
    symbol: TComboBox;
    connoption: TComboBox;
    comment: TEdit;
    latitude: TEdit;
    longtitude: TEdit;
    GroupBox1: TGroupBox;
    GroupBox2: TGroupBox;
    Label10: TLabel;
    Label11: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    OpenDialog1: TOpenDialog;
    PageControl1: TPageControl;
    Path2: TComboBox;
    pspeed: TComboBox;
    SaveDialog1: TSaveDialog;
    StatusBar1: TStatusBar;
    tab_main: TTabSheet;
    tab_komunikacja: TTabSheet;
    temp: TCheckBox;
    Timer1: TTimer;
    Timer2: TTimer;
    timing: TComboBox;
    timing1: TComboBox;
    timing2: TComboBox;
    timing3: TComboBox;
    timing4: TComboBox;
    timing5: TComboBox;
    zaprogramuj: TButton;
    zaprogramuj1: TButton;
    //procedure CheckBox1Change(Sender: TObject);
    procedure clearClick(Sender: TObject);
    procedure Memo1Change(Sender: TObject);
    procedure MenuItem2Click(Sender: TObject);

    //procedure destaddChange(Sender: TObject);
    procedure MenuItem3Click(Sender: TObject);
    procedure MenuItem4Click(Sender: TObject);
    procedure MenuItem5Click(Sender: TObject);
    procedure MenuItem6Click(Sender: TObject);
    procedure MenuItem9Click(Sender: TObject);
    procedure odczytajClick(Sender: TObject);
    procedure sendClick(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
    procedure zaprogramuj1Click(Sender: TObject);
    procedure zaprogramujClick(Sender: TObject);
    procedure connoptionEditingDone(Sender: TObject);
    procedure destaddEditingDone(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    //procedure MySQL55Connection1AfterConnect(Sender: TObject);
    procedure pspeedEditingDone(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
    appname: string;
    ConfFN : string;
    polaczony: integer;
    reading: integer;
    delay_time: integer;
    PortCom: TBlockSerial;
    INI:TINIFile;
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.zaprogramujClick(Sender: TObject);
//var
  //sciezka: string;
begin
     //PortCom := TBlockSerial.Create;
     //PortCom.RaiseExcept := false;
     //PortCom.Connect(connoption.Text);
     sleep(500);
     progressBar1.position := progressBar1.position + 5;
     PortCom.Config(strtoint(trim(pspeed.text)),8,'N',0,false,false);
     sleep(500);
     progressBar1.position := progressBar1.position + 5;
        PortCom.SendString('beac='+trim(timing.Text)+'*'+trim(callsign.text)+'*'+trim(Combobox1.Text)+'*'+path2.text+'*'+latitude.text+table.text+longtitude.text+symbol.text+trim(comment.text)+CRLF);
        progressBar1.position := progressBar1.position + 5;
        sleep(700);

        PortCom.SendString('obj1='+trim(timing1.Text)+'*'+ trim(callsign1.text)+'*'+path3.text+'*'+latitude1.text+table1.text+longtitude1.text+symbol1.text+trim(comment1.text)+CRLF);
        progressBar1.position := progressBar1.position + 5;
        sleep(700);

        PortCom.SendString('obj2='+trim(timing2.Text)+'*'+trim(callsign2.text)+'*'+path4.text+'*'+latitude2.text+table2.text+longtitude2.text+symbol2.text+trim(comment2.text)+CRLF);
        progressBar1.position := progressBar1.position + 5;
        sleep(700);

        PortCom.SendString('obj3='+trim(timing3.Text)+'*'+trim(callsign3.text)+'*'+path5.text+'*'+latitude3.text+table3.text+longtitude3.text+symbol3.text+trim(comment3.text)+CRLF);
        progressBar1.position := progressBar1.position + 5;
        sleep(700);

        PortCom.SendString('obj4='+trim(timing4.Text)+'*'+trim(callsign4.text)+'*'+path6.text+'*'+latitude4.text+table4.text+longtitude4.text+symbol4.text+trim(comment4.text)+CRLF);
        progressBar1.position := progressBar1.position + 5;
        sleep(700);

        PortCom.SendString('obj5='+trim(timing5.Text)+'*'+trim(callsign5.text)+'*'+path7.text+'*'+latitude5.text+table5.text+longtitude5.text+symbol5.text+trim(comment5.text)+CRLF);
        progressBar1.position := progressBar1.position + 5;
        sleep(700);
     ProgressBar1.position := 100;
     //PortCom.CloseSocket;
     //PortCom.Free;
     sleep(500);
     progressBar1.position := 0;

     //ten blok zamienić na wywolanie funkcji dla oszczędzenia ilosci kodu
     zaprogramuj1.caption := 'połącz';
     MenuItem2.caption := 'połącz';
     timer1.enabled:=false;
     timer2.enabled:=false;
     zaprogramuj.enabled := false;
     odczytaj.enabled := false;
     send.enabled := false;
     clear.enabled := false;
     MenuItem10.enabled :=false;
     MenuItem11.enabled :=false;
     polaczony :=0;
     PortCom.CloseSocket;
     PortCom.Free;
     memo1.Clear;
     //koniec bloku do wymiany...

end;

procedure TForm1.odczytajClick(Sender: TObject);

begin
     delay_time:=0;
     timer2.enabled:=false;
     memo1.clear;
     PortCom.SendString('readc'+LF+CR);
     reading :=1;
end;

procedure TForm1.sendClick(Sender: TObject);
begin

end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
  //surowa_rameczka:string;
  cos_jest: integer;
begin
  cos_jest := PortCom.WaitingData;
  if cos_jest > 0 then
    begin
         memo1.lines.add(PortCom.Recvstring(5));
         if reading = 1 then
           begin
             ProgressBar1.position := ProgressBar1.position +10;
           end;
    end;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
  delay_time:=delay_time+1;
  if (memo1.lines.count < 2) AND (delay_time > 5) then
    begin
//ten blok zamienić na wywolanie funkcji dla oszczędzenia ilosci kodu
zaprogramuj1.caption := 'połącz';
MenuItem2.caption := 'połącz';
timer1.enabled:=false;
timer2.enabled:=false;
zaprogramuj.enabled := false;
odczytaj.enabled := false;
send.enabled := false;
clear.enabled := false;
MenuItem10.enabled :=false;
MenuItem11.enabled :=false;
polaczony :=0;
PortCom.CloseSocket;
PortCom.Free;
memo1.Clear;
//koniec bloku do wymiany...
       MessageDlg('blad polaczenia sprawdź czy wybrales odpowiedni port oraz czy kabel jest podlaczony',mtError, mbOKCancel, 0);
    end;
end;


procedure TForm1.zaprogramuj1Click(Sender: TObject);
begin
  if polaczony = 0 then
    begin
         zaprogramuj1.caption := 'rozłącz';
         MenuItem2.caption := 'rozłącz';
         PortCom := TBlockSerial.Create;
         PortCom.RaiseExcept := false;
         PortCom.Connect(connoption.Text);
         PortCom.Config(strtoint(trim(pspeed.text)),8,'N',0,false,false);
         timer1.enabled:=true;
         timer2.enabled:=true;
         delay_time:=0;
         zaprogramuj.enabled := true;
         odczytaj.enabled := true;
         send.enabled := true;
         clear.enabled := true;
         MenuItem10.enabled :=true;
         MenuItem11.enabled :=true;
         polaczony :=1;
         memo1.lines.add('ver?');
         PortCom.SendString('ver'+LF+CR);
         //sleep(1000);
            //ShowMessage(Memo1.Lines.Strings[1]);
         //if trim(Memo1.Lines.Strings[1]) = '2.10' then
         //  begin
         //    ShowMessage('polaczenie OK wersja zgodna');
         //    ShowMessage(Memo1.Lines.Strings[1]);
         //  end;
    end
  else
    begin
         zaprogramuj1.caption := 'połącz';
         MenuItem2.caption := 'połącz';
         timer1.enabled:=false;
         timer2.enabled:=false;
         zaprogramuj.enabled := false;
         odczytaj.enabled := false;
         send.enabled := false;
         clear.enabled := false;
         MenuItem10.enabled :=false;
         MenuItem11.enabled :=false;
         polaczony :=0;
         PortCom.CloseSocket;
         PortCom.Free;
         memo1.Clear;
    end;


end;

procedure TForm1.MenuItem9Click(Sender: TObject);
begin
  //tutaj okno dialog z informacją o autorze pomocy strona itd...
  ShowMessage(appname+CRLF+'Copyright Ryszard Labus SQ9MDD 2013'+CRLF+'Udostępniam na licencji GPL');
end;

procedure TForm1.MenuItem5Click(Sender: TObject);
var
   //f:textFile;
   licznik: integer;
begin
  SaveDialog1.FileName :=  CallSign.text + '-APRSPlatform.ini';
  if SaveDialog1.Execute then begin
     for licznik:=1 to 2 do
     begin
     if (licznik = 1) then begin
        INI := TINIFile.Create(SaveDialog1.Filename);
     end;
     if (licznik = 2) then begin
        INI := TINIFile.Create('APRSConf.ini');
     end;
     //a tutaj zapisujemy bieżącą konfigurację do nowego pliku ini
     INI.Writestring('CON','port',connoption.text);
     INI.Writestring('CON','speed',pspeed.text);
     //glowna zakladka
     INI.Writestring('MAIN','callsign',CallSign.text);
     INI.Writestring('MAIN','ssid',ComboBox1.text);
     INI.Writestring('MAIN','path',Path2.text);
     INI.Writestring('MAIN','symbol',symbol.text);
     INI.Writestring('MAIN','table',table.text);
     INI.Writestring('MAIN','comment',comment.text);
     INI.Writestring('MAIN','latitude',latitude.text);
     INI.Writestring('MAIN','longtitude',longtitude.text);
     INI.Writestring('MAIN','timing',timing.text);
     //obj1
     INI.Writestring('OBJ1','callsign',CallSign1.text);
     INI.Writestring('OBJ1','path',Path3.text);
     INI.Writestring('OBJ1','symbol',symbol1.text);
     INI.Writestring('OBJ1','table',table1.text);
     INI.Writestring('OBJ1','comment',comment1.text);
     INI.Writestring('OBJ1','latitude',latitude1.text);
     INI.Writestring('OBJ1','longtitude',longtitude1.text);
     INI.Writestring('OBJ1','timing',timing1.text);
     //obj2
     INI.Writestring('OBJ2','callsign',CallSign2.text);
     INI.Writestring('OBJ2','path',Path4.text);
     INI.Writestring('OBJ2','symbol',symbol2.text);
     INI.Writestring('OBJ2','table',table2.text);
     INI.Writestring('OBJ2','comment',comment2.text);
     INI.Writestring('OBJ2','latitude',latitude2.text);
     INI.Writestring('OBJ2','longtitude',longtitude2.text);
     INI.Writestring('OBJ2','timing',timing2.text);
     //obj3
     INI.Writestring('OBJ3','callsign',CallSign3.text);
     INI.Writestring('OBJ3','path',Path5.text);
     INI.Writestring('OBJ3','symbol',symbol3.text);
     INI.Writestring('OBJ3','table',table3.text);
     INI.Writestring('OBJ3','comment',comment3.text);
     INI.Writestring('OBJ3','latitude',latitude3.text);
     INI.Writestring('OBJ3','longtitude',longtitude3.text);
     INI.Writestring('OBJ3','timing',timing3.text);
     //obj4
     INI.Writestring('OBJ4','callsign',CallSign4.text);
     INI.Writestring('OBJ4','path',Path6.text);
     INI.Writestring('OBJ4','symbol',symbol4.text);
     INI.Writestring('OBJ4','table',table4.text);
     INI.Writestring('OBJ4','comment',comment4.text);
     INI.Writestring('OBJ4','latitude',latitude4.text);
     INI.Writestring('OBJ4','longtitude',longtitude4.text);
     INI.Writestring('OBJ4','timing',timing4.text);
     //obj5
     INI.Writestring('OBJ5','callsign',CallSign5.text);
     INI.Writestring('OBJ5','path',Path7.text);
     INI.Writestring('OBJ5','symbol',symbol5.text);
     INI.Writestring('OBJ5','table',table5.text);
     INI.Writestring('OBJ5','comment',comment5.text);
     INI.Writestring('OBJ5','latitude',latitude5.text);
     INI.Writestring('OBJ5','longtitude',longtitude5.text);
     INI.Writestring('OBJ5','timing',timing5.text);

       if(temp.checked=true)then begin
          INI.Writestring('MAIN','temp','true');
       end;
       if(temp.checked=false)then begin
          INI.Writestring('MAIN','temp','false');
       end;
       if(napiecie.checked=true)then begin
          INI.Writestring('MAIN','napiecie','true');
       end;
       if(napiecie.checked=false)then begin
          INI.Writestring('MAIN','napiecie','false');
       end;
  end;
   INI.Destroy;
end;
  ConfFN := SaveDialog1.FileName;
  form1.caption:= appname + '(' + SaveDialog1.FileName + ')';
end;

procedure TForm1.clearClick(Sender: TObject);
begin
  PortCom := TBlockSerial.Create;
  PortCom.RaiseExcept := false;
  PortCom.Connect(connoption.Text);
  PortCom.Config(strtoint(trim(pspeed.text)),8,'N',0,false,false);
  PortCom.SendString('clsme'+CRLF);
  sleep(5000);
  PortCom.SendString('reset'+CRLF);
  PortCom.CloseSocket;
  PortCom.Free;
end;

procedure TForm1.Memo1Change(Sender: TObject);
var
   a: integer;
   at: string;
begin
  //po polaczeniu sprawdzam czy wersja jest zgodna
  if (reading = 0) AND (Memo1.Lines.Count = 2) then
    begin
         if trim(Memo1.Lines.Strings[1]) = '2.10' then
           begin
             ShowMessage('połączenie OK wersja programu i urządzenia zgodna');
             //ShowMessage(Memo1.Lines.Strings[1]);
           end
         else //jesli wersja nie jest zgodna to komunikat i rozłącz
         begin
            //ShowError('blad polaczenia wersja oprogramowania i wersja APRS platform nie zgodna');
            MessageDlg('bląd połączenia wersja oprogramowania i wersja urządzenia nie jest zgodna',mtError, mbOKCancel, 0);
            //ten blok zamienić na wywolanie funkcji dla oszczędzenia ilosci kodu
            zaprogramuj1.caption := 'połącz';
            MenuItem2.caption := 'połącz';
            timer1.enabled:=false;
            zaprogramuj.enabled := false;
            odczytaj.enabled := false;
            send.enabled := false;
            clear.enabled := false;
            MenuItem10.enabled :=false;
            MenuItem11.enabled :=false;
            polaczony :=0;
            PortCom.CloseSocket;
            PortCom.Free;
            memo1.Clear;
            //koniec bloku do wymiany...
         end;
    end;
  if (Memo1.Lines.Count = 6) AND (reading =1) then
    begin
     //timingi
     timing.text := copy(memo1.lines[0],6,2);
     timing1.text := copy(memo1.lines[1],6,2);
     timing2.text := copy(memo1.lines[2],6,2);
     timing3.text := copy(memo1.lines[3],6,2);
     timing4.text := copy(memo1.lines[4],6,2);
     timing5.text := copy(memo1.lines[5],6,2);
        //znak podstawowy
        a := AnsiPos('*',memo1.lines[0]);
        at := copy (memo1.lines[0],(a+1),255);
        a := AnsiPos('*',at);
        Callsign.text := copy (at,0,a-1);   //znak
        at := copy (at,(a+1),255);
        a := AnsiPos('*',at);
        ComboBox1.text := copy(at,0,a-1);   //ssid
        at := copy (at,(a+1),255);
        a := AnsiPos('*',at);
        Path2.text := copy(at,0,a-1);        //path
        at := copy (at,(a+1),255);
        latitude.text := copy(at,0,8);
        longtitude.text := copy(at,10,9);
        comment.text := trim(copy(at,20,255));
        table.text := copy(at,9,1);
        symbol.text := copy(at,19,1);
        //ShowMessage(at);

        //obj1
        a := AnsiPos('*',memo1.lines[1]);
        at := copy (memo1.lines[1],(a+1),255);
        a := AnsiPos('*',at);
        Callsign1.text := copy (at,0,a-1);   //znak
        at := copy (at,(a+1),255);
        a := AnsiPos('*',at);
        Path3.text := copy(at,0,a-1);        //path
        at := copy (at,(a+1),255);
        latitude1.text := copy(at,0,8);
        longtitude1.text := copy(at,10,9);
        comment1.text := trim(copy(at,20,255));
        table1.text := copy(at,9,1);
        symbol1.text := copy(at,19,1);
        //ShowMessage(at);

        //obj2
        a := AnsiPos('*',memo1.lines[2]);
        at := copy (memo1.lines[2],(a+1),255);
        a := AnsiPos('*',at);
        Callsign2.text := copy (at,0,a-1);   //znak
        at := copy (at,(a+1),255);
        a := AnsiPos('*',at);
        Path4.text := copy(at,0,a-1);        //path
        at := copy (at,(a+1),255);
        latitude2.text := copy(at,0,8);
        longtitude2.text := copy(at,10,9);
        comment2.text := trim(copy(at,20,255));
        table2.text := copy(at,9,1);
        symbol2.text := copy(at,19,1);
        //ShowMessage(at);

        //obj3
        a := AnsiPos('*',memo1.lines[3]);
        at := copy (memo1.lines[3],(a+1),255);
        a := AnsiPos('*',at);
        Callsign3.text := copy (at,0,a-1);   //znak
        at := copy (at,(a+1),255);
        a := AnsiPos('*',at);
        Path5.text := copy(at,0,a-1);        //path
        at := copy (at,(a+1),255);
        latitude3.text := copy(at,0,8);
        longtitude3.text := copy(at,10,9);
        comment3.text := trim(copy(at,20,255));
        table3.text := copy(at,9,1);
        symbol3.text := copy(at,19,1);
        //ShowMessage(at);

        //obj4
        a := AnsiPos('*',memo1.lines[4]);
        at := copy (memo1.lines[4],(a+1),255);
        a := AnsiPos('*',at);
        Callsign4.text := copy (at,0,a-1);   //znak
        at := copy (at,(a+1),255);
        a := AnsiPos('*',at);
        Path6.text := copy(at,0,a-1);        //path
        at := copy (at,(a+1),255);
        latitude4.text := copy(at,0,8);
        longtitude4.text := copy(at,10,9);
        comment4.text := trim(copy(at,20,255));
        table4.text := copy(at,9,1);
        symbol4.text := copy(at,19,1);
        //ShowMessage(at);

        //obj5
        a := AnsiPos('*',memo1.lines[5]);
        at := copy (memo1.lines[5],(a+1),255);
        a := AnsiPos('*',at);
        Callsign5.text := copy (at,0,a-1);   //znak
        at := copy (at,(a+1),255);
        a := AnsiPos('*',at);
        Path7.text := copy(at,0,a-1);        //path
        at := copy (at,(a+1),255);
        latitude5.text := copy(at,0,8);
        longtitude5.text := copy(at,10,9);
        comment5.text := trim(copy(at,20,255));
        table5.text := copy(at,9,1);
        symbol5.text := copy(at,19,1);
        //ShowMessage(at);

         if reading = 1 then
           begin
             ProgressBar1.position := 100;
             sleep(2000);
             ProgressBar1.position := 0;
             reading := 0;
             //ten blok zamienić na wywolanie funkcji dla oszczędzenia ilosci kodu
            // zaprogramuj1.caption := 'połącz';
            // MenuItem2.caption := 'połącz';
            // timer1.enabled:=false;
            // zaprogramuj.enabled := false;
            // odczytaj.enabled := false;
            // send.enabled := false;
            // clear.enabled := false;
            // MenuItem10.enabled :=false;
            // MenuItem11.enabled :=false;
            // polaczony :=0;
            // PortCom.CloseSocket;
            // PortCom.Free;
            // memo1.Clear;
             //koniec bloku do wymiany...
           end;

         //ShowMessage(inttostr(a));
         //ShowMessage(at);

    end;
end;

procedure TForm1.MenuItem2Click(Sender: TObject);
begin

end;

procedure TForm1.MenuItem3Click(Sender: TObject);
begin

end;

procedure TForm1.MenuItem4Click(Sender: TObject);
begin

end;

procedure TForm1.MenuItem6Click(Sender: TObject);
begin
  application.terminate;
end;

procedure TForm1.connoptionEditingDone(Sender: TObject);
begin
  INI := TINIFile.Create('APRSConf.ini');
  INI.Writestring('CON','port',connoption.text);
end;

procedure TForm1.destaddEditingDone(Sender: TObject);
begin
  INI := TINIFile.Create('APRSConf.ini');
  //INI.Writestring('OPT','destadd',destadd.text);
end;

procedure TForm1.FormCreate(Sender: TObject);
var
   //F:TextFile;
   l: string;
   p: integer;
begin
  appname:= 'APRS Platform Configurator v.2.1 beta';
  PageControl1.ActivePage:=tab_main;
  form1.caption:= appname;
  polaczony := 0;
  reading:=0;

  //ladowanie ustawien z pliku ini
  //ustawienia
  INI := TINIFile.Create('APRSConf.ini');
  connoption.text := INI.ReadString('CON','port','');
  pspeed.text := INI.ReadString('CON','speed','');
  //zakladka glowna
  //CallSign.text := INI.ReadString('MAIN','callsign','NOLIC');
  //ComboBox1.text := INI.ReadString('MAIN','ssid','0');
  //Path2.text := INI.ReadString('MAIN','path','path');
  //symbol.text := INI.ReadString('MAIN','symbol','symbol');
  //table.text := INI.ReadString('MAIN','table','table');
  //comment.text := INI.ReadString('MAIN','comment','enter comment here');
  //latitude.text := INI.ReadString('MAIN','latitude','latitude (N/S)');
  //longtitude.text := INI.ReadString('MAIN','longtitude','longtitude (W/E)');
  //timing.text := INI.ReadString('MAIN','timing','255');
  //obj1
  //CallSign1.text := INI.ReadString('OBJ1','callsign','NOLIC');
  //Path3.text := INI.ReadString('OBJ1','path','path');
  //symbol1.Items.Add(INI.ReadString('OBJ1','symbol','symbol'));
  //table1.text := INI.ReadString('OBJ1','table','table');
  //comment1.text := INI.ReadString('OBJ1','comment','enter comment here');
  //latitude1.text := INI.ReadString('OBJ1','latitude','latitude (N/S)');
  //longtitude1.text := INI.ReadString('OBJ1','longtitude','longtitude (W/E)');
  //timing1.text := INI.ReadString('OBJ1','timing','255');
  //obj2
  //CallSign2.text := INI.ReadString('OBJ2','callsign','NOLIC');
  //Path4.text := INI.ReadString('OBJ2','path','path');
  //symbol2.text := INI.ReadString('OBJ2','symbol','symbol');
  //table2.text := INI.ReadString('OBJ2','table','table');
  //comment2.text := INI.ReadString('OBJ2','comment','enter comment here');
  //latitude2.text := INI.ReadString('OBJ2','latitude','latitude (N/S)');
  //longtitude2.text := INI.ReadString('OBJ2','longtitude','longtitude (W/E)');
  //timing2.text := INI.ReadString('OBJ2','timing','255');
  //obj3
  //CallSign3.text := INI.ReadString('OBJ3','callsign','NOLIC');
  //Path5.text := INI.ReadString('OBJ3','path','path');
  //symbol3.text := INI.ReadString('OBJ3','symbol','symbol');
  //table3.text := INI.ReadString('OBJ3','table','table');
  //comment3.text := INI.ReadString('OBJ3','comment','enter comment here');
  //latitude3.text := INI.ReadString('OBJ3','latitude','latitude (N/S)');
  //longtitude3.text := INI.ReadString('OBJ3','longtitude','longtitude (W/E)');
  //timing3.text := INI.ReadString('OBJ3','timing','255');
  //obj4
  //CallSign4.text := INI.ReadString('OBJ4','callsign','NOLIC');
  //Path6.text := INI.ReadString('OBJ4','path','path');
  //symbol4.text := INI.ReadString('OBJ4','symbol','symbol');
  //table4.text := INI.ReadString('OBJ4','table','table');
  //comment4.text := INI.ReadString('OBJ4','comment','enter comment here');
  //latitude4.text := INI.ReadString('OBJ4','latitude','latitude (N/S)');
  //longtitude4.text := INI.ReadString('OBJ4','longtitude','longtitude (W/E)');
  //timing4.text := INI.ReadString('OBJ4','timing','255');
  //obj5
  //CallSign5.text := INI.ReadString('OBJ5','callsign','NOLIC');
  //Path7.text := INI.ReadString('OBJ5','path','path');
  //symbol5.text := INI.ReadString('OBJ5','symbol','symbol');
  //table5.text := INI.ReadString('OBJ5','table','table');
  //comment5.text := INI.ReadString('OBJ5','comment','enter comment here');
  //latitude5.text := INI.ReadString('OBJ5','latitude','latitude (N/S)');
  //longtitude5.text := INI.ReadString('OBJ5','longtitude','longtitude (W/E)');
  //timing5.text := INI.ReadString('OBJ5','timing','255');

  //destadd.text := INI.ReadString('OPT','destadd','APZMDD');
  //quiettime.text := INI.ReadString('OPT','quiettime','15');
  //checkbox temperature
  if(INI.ReadString('MAIN','temp','false')='false') then begin
     //temp.checked := false;
  end;
  if(INI.ReadString('MAIN','temp','false')='true') then begin
     //temp.checked := true;
     //comment.maxlength :=  comment.maxlength -5;
  end;
  //checkbox pomiar napiecia
  if(INI.ReadString('MAIN','napiecie','false')='false') then begin
     //napiecie.checked := false;
  end;
  if(INI.ReadString('MAIN','napiecie','false')='true') then begin
     //napiecie.checked := true;
     //comment.maxlength :=  comment.maxlength -5;
  end;
  l := GetSerialPortNames;
    if l >'' then repeat
      begin
      p :=  pos(',',l);
      if p > 0 then
        begin
        connoption.Items.Add(copy(L,1,p-1));
        delete(L,1,p);
        end
      else
        connoption.Items.Add(L);
      end;
      until p = 0;
    //INI.Destroy;
end;

procedure TForm1.pspeedEditingDone(Sender: TObject);
begin
  INI := TINIFile.Create('APRSConf.ini');
  INI.Writestring('CON','speed',pspeed.text);
end;

end.

